#include "dish_operation.h"
#include "ui_dish_operation.h"

dish_operation::dish_operation(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::dish_operation){
  static int order_num1;
   static int order_num2;
static  int order_num3;
    price1 = config.dishList[0].price;
    price2 = config.dishList[1].price;
    price3 = config.dishList[2].price;
  static  QString rm1;
  static  QString rm2;
   static QString rm3;
//qDebug()<<price1 ;

    ui->setupUi(this);

    ui->price1->display(config.dishList[0].price);

    ui->price2->display(config.dishList[1].price);
    ui->price3->display(config.dishList[2].price);

    ui->firstdishtext->insert(config.dishList[0].dishName);
    ui->seconddishtext->insert(config.dishList[1].dishName);
    ui->thirddishtext->insert(config.dishList[2].dishName);
ui->discription1->append(config.dishList[0].description);
ui->discription2->append(config.dishList[1].description);
ui->discription3->append(config.dishList[2].description);

    //确定点餐
   connect(ui->Order_dish,&QPushButton::clicked,[=](){

Order order1(ui->firstdishtext->text(),order_num1,rm1);
 qDebug() << ui->firstdishtext->text();
  qDebug() <<order_num1;
   qDebug() <<rm1;
Order order2(ui->seconddishtext->text(),order_num2,rm2);
Order order3(ui->thirddishtext->text(),order_num3,rm3);

//不带用户名的orderlist
 QVector<Order> list;

 list.push_back(order1);
 list.push_back(order2);
 list.push_back(order3);

//带用户名的orderlist
Orderlist list1;
list1.orderList = list;
list1.userName = currentUser;

//
config.orderList.append(list1);


    ui->total_price->display(totalprice);
       });


       //第一个菜下按钮
       connect(ui->firstdishbutton,&QPushButton::clicked,[=](){

              QString str1 =   ui->firstdishtext->text();


              rm1 +=   ui->remark1->text();
              str1+=":";
                     str1+= rm1;
  ui->remark1->clear();
                      order_num1++;
                    totalprice += price1;
                  ui->show_dish1->append(str1);


       });


           //第二个菜下按钮
       connect(ui->seconddishbutton,&QPushButton::clicked,[=](){
            ui->remark2->text();
              QString str2 =   ui->seconddishtext->text();
               rm2 +=   ui->remark2->text();
               str2+=":";
                      str2+= rm2;
                 ui->remark2->clear();
                totalprice += price2;
                 order_num2++;
                  ui->show_dish2->append(str2);

       });


           //第三个菜下按钮
       connect(ui->thirddishbutton,&QPushButton::clicked,[=](){
            ui->remark3->text();
              QString str3 =   ui->thirddishtext->text();
               rm3 +=   ui->remark3->text();
                str3+=":";
                      str3+= rm3;
                 ui->remark3->clear();
                    totalprice += price3;
                      order_num3++;
                  ui->show_dish3->append(str3);
       });



    connect(ui->backToLogin, &QPushButton::clicked,[=](){
        MainWindow * login = new MainWindow;
        this->hide();
        login->show();
    });




}


dish_operation::~dish_operation()
{
    delete ui;
}
